/**
 * 仅商品详情页，不能用于编辑
 */
export default [
  {
    type: "image",
    prop: "${list}",
    label: "商品图片",
    upKey: "address",
    repeat: true,
    check_value(value) {
      value = value[0] || {};
      if (!value.url) {
        return [];
      }
      if (typeof value.url === "string") {
        return [value.url];
      }
      return value.url;
    },
  },
  {
    type: "text",
    prop: "${list}1",
    label: "商品名称",
    check_value(value) {
      value = value[0] || {};
      return value.productName;
    },
  },
  {
    type: "text",
    label: "商品规格",
    prop: "${list}2",
    check_value(value) {
      value = value[0] || {};
      return value.specification;
    },
  },
  {
    type: "text",
    label: "商品编号",
    prop: "${list}3",
    check_value(value) {
      value = value[0] || {};
      return value.productCode;
    },
  },
  {
    type: "text",
    label: "数量",
    prop: "${list}4",
    check_value(value) {
      value = value[0] || {};
      return value.num;
    },
  },
  {
    type: "text",
    label: "订单金额",
    prop: "orderFee",
  },
  {
    type: "datetime",
    label: "下单时间",
    prop: "gmtCreated",
  },
  {
    type: "text",
    label: "用户",
    prop: "contact",
  },
  {
    type: "text",
    label: "用户电话",
    prop: "mobile",
  },
  {
    type: "text",
    label: "展会信息",
    prop: "exhibitionName",
  },
  {
    type: "text",
    label: "收货地址",
    prop: "address",
  },
  {
    type: "text",
    label: "租贡日期",
    prop: "${list}8",
    show(data) {
      return data.orderType === "LEASE";
    },
    check_value(value) {
      const dateReg = /\d{4}-\d{2}-\d{2}/;
      value = value[0] || {};
      return `${value.startTime ? value.startTime.match(dateReg)[0] : "/"} -- ${
        value.endTime ? value.endTime.match(dateReg)[0] : "/"
      }`;
    },
  },
  {
    type: "text",
    label: "优惠信息",
    prop: "discounts",
    view(formData) {
      if (formData.popupDTO) {
        return `满${formData.popupDTO.fullMoney}减${formData.popupDTO.discounts}`;
      }
      return "无";
    },
  },
  {
    type: "text",
    label: "实付金额",
    prop: "practical",
  },
  {
    type: "text",
    label: "商家姓名",
    prop: "${miniMerchantDTO}1",
    topLine: true,
    check_value(value) {
      return value && value.merchantName;
    },
    show(fromData) {
      return fromData && fromData.miniMerchantDTO;
    },
  },
  {
    type: "text",
    label: "商家电话",
    prop: "${miniMerchantDTO}2",
    check_value(value) {
      return value && value.mobile;
    },
    show(fromData) {
      return fromData && fromData.miniMerchantDTO;
    },
  },
  {
    type: "text",
    label: "商家地址",
    prop: "${miniMerchantDTO}3",
    check_value(value) {
      return value && value.address;
    },
    show(fromData) {
      return fromData && fromData.miniMerchantDTO;
    },
  },
  {
    type: "rate",
    label: "评价",
    prop: "${commentDTO}1",
    topLine: true,
    show(fromData) {
      return fromData && fromData.isComment;
    },
    check_value(value = {}) {
      return value && (value.num || 0);
    },
  },
  {
    type: "text",
    label: "评价内容",
    prop: "${commentDTO}2",
    show(fromData) {
      return fromData && fromData.isComment;
    },
    check_value(value = {}) {
      return (value && value.body) || 0;
    },
  },
];
